// pages/logs/logs.js
const util= require('../../utils/util.js')
Page({
  data: {
    logs:[]
  },
  getlogs:function(){
    const that =this
      const ui = wx.getStorageSync('userInfo')
      //console.log("A:",ui)
      if(!ui.openid){
        wx.switchTab({
          url: '/pages/me/me',
        })
      }else{
        wx.cloud.callFunction({
          name:"getlogs",
          data:{
            openid:ui.openid
          },
          success:res=>{
            console.log("res请求成功",res);
            that.setData({
              logs:res.result.data.map(log=>{
                var date = util.formatTime(new Date(log.date))
                log.date=date
                return log
              })
            })
          },
          fail:res=>{
            console.log("res请求失败",res)
          }
        })
        }
  },
  onShow:function(){
    this.getlogs()
  }
})